﻿using System.Collections.Generic;
using BoutiquePOS.DAL.DAO;
using BoutiquePOS.DAL.Gateway;

namespace BoutiquePOS.Manager
{
    public class ShelfManager
    {
        ShelfGateway shelfGateway = new ShelfGateway();

        public string SaveShelf(Shelf shelf)
        {
            if (!DoesThisShelfExist(shelf))
                return shelfGateway.SaveShelf(shelf);
            else
            {
                return "This Shelf Already Exists";
            }
        }
        private bool DoesThisShelfExist(Shelf shelf)
        {
            List<Shelf> shelfs = new List<Shelf>();
            shelfs = shelfGateway.GetAllShelf();

            foreach (Shelf rackObj in shelfs)
            {
                if (rackObj.ShelfName == shelf.ShelfName)
                    return true;
            }
            return false;
        }

        public List<Shelf> GetAllShelf()
        {
            return shelfGateway.GetAllShelf();
        }

        public string DeleteShelf(int shelfId)
        {
            string message = shelfGateway.DeleteShelfById(shelfId);
            return message;
        }
        public List<Shelf> GetAllShelfByIdOrName(int i, string Id)
        {
            return shelfGateway.GetAllShelfByCodeOrName(i, Id);
        }
    }
}